//
//  APPublishWorksNaviBar.m
//  AqualPolo
//
//  Created by dong on 2024/5/12.
//

#import "APPublishWorksNaviBar.h"

@interface APPublishWorksNaviBar ()
@property (nonatomic, strong) UIView *contentView;
@end

@implementation APPublishWorksNaviBar

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _contentView = [[UIView alloc] init];
        [self addSubview:_contentView];
        [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(20);
            make.left.right.equalTo(self);
            make.height.mas_equalTo(44);
            make.bottom.equalTo(self);
        }];
        
        _backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_backButton setImage:[UIImage imageNamed:@"back_blue"] forState:UIControlStateNormal];
        [_contentView addSubview:_backButton];
        [_backButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_contentView).offset(20);
            make.top.bottom.equalTo(_contentView);
        }];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.font = [LYFont fontWithSize:18 fontName:LYFontNamepfr];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [_contentView addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(_contentView);
            make.left.right.equalTo(self);
        }];
        
        _publishButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _publishButton.titleLabel.font = [LYFont fontWithSize:18 fontName:LYFontNamepfb];
        _publishButton.backgroundColor = LYRGBColor(87, 61, 255);
        _publishButton.layer.cornerRadius = 8;
        _publishButton.layer.masksToBounds = true;
        _publishButton.layer.shadowColor = LYRGBColor(68, 45, 220).CGColor;
        _publishButton.layer.shadowOffset = CGSizeMake(2, 2);
        _publishButton.layer.shadowOpacity = 1;
        _publishButton.layer.shadowRadius = 8;
        [_publishButton setTitle:@"Post" forState:UIControlStateNormal];
        [_contentView addSubview:_publishButton];
        [_publishButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(_contentView).offset(-20);
            make.centerY.equalTo(_contentView);
            make.size.mas_equalTo(CGSizeMake(71, 32));
        }];
        
    }
    return self;
}


- (void)safeAreaInsetsDidChange{
    [super safeAreaInsetsDidChange];
    [_contentView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(self.safeAreaInsets.top);
    }];
}

@end
